package cci.jdbc;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

public class ConnexionJavaDB {

	private static DataSource datasource ;
	
	public static DataSource getInstance(){
		
		if (datasource == null) {
							
			try {
				Context initCtx = new InitialContext();
				datasource = (DataSource) initCtx.lookup("java:comp/env/jdbc/Demo");
			} catch (Exception e){
				System.err.println("Erreur lors de la connexion : " + e);
			}
		}
		
		return datasource ;
		
	}

	
}
